<template>
  <div>
    <el-container>
      <el-header>
        <el-menu :default-active="activeIndex" mode="horizontal">
          <el-menu-item
            :index="(index+'')"
            v-for="(S,index) in ScheDate"
            :key="index"
            @click="GetScheByDate(S.date);"
          >{{S.date}}</el-menu-item>
        </el-menu>
      </el-header>
      <el-main>
        <Ticket1 :key="id"></Ticket1>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import Ticket1 from "@/views/Ticket1";
export default {
  components: {
    Ticket1
  },
  data() {
    return {
      activeIndex: "0",
      ScheDate: null,
      ScheInfo: null,
      id: +new Date(),
      MovieID: this.$store.state.MovieId
    };
  },
  created() {
     console.log(this.$store.state.MovieName)
      console.log(this.$store.state.MovieId)
      console.log(this.MovieID)
    this.Ajax.get(
      "api/Schedule/GetSche?MovieID=" + this.$store.state.MovieId
    ).then(S => {
      this.ScheDate = S.data;
      this.GetScheByDate(this.ScheDate[0].date);
    });
  },
  mounted() {
    
  },
  methods: {
    GetScheByDate(date) {
      this.Ajax.post("api/Schedule/GetScheByDate", {
        data: {
          MovieID: this.MovieID,
          Schedate: date
        }
      }).then(S => {
        this.ScheInfo = S.data;
        this.id=+new Date()
        console.log(S.data)
        this.$store.commit("UpdateScheInfo", S.data);
        
      });
    }
  }
};
</script>